﻿#include "ace.Profile.h"
using namespace std;

namespace ace
{
	Performance::Performance()
		: m_startTime(-1), m_endTime(-1), m_processorNumber(-1)
	{
	}

	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	int Performance::GetStartTime() const
	{
		return m_startTime;
	}

	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	void Performance::SetStartTime(int value)
	{
		m_startTime = value;
	}

	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	int Performance::GetEndTime() const
	{
		return m_endTime;
	}

	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	void Performance::SetEndTime(int value)
	{
		m_endTime = value;
	}

	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	int Performance::GetProcessorNumber() const
	{
		return m_processorNumber;
	}

	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	void Performance::SetProcessorNumber(int value)
	{
		m_processorNumber = value;
	}


	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	Profile::Profile(int id)
		: m_id(id)
		, m_performances(std::stack<Profile::PerfPtr>())
		, m_current(make_shared<Performance>())
	{
	}

	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	Profile::PerfPtr Profile::GetCurrent()
	{
		return m_current;
	}

	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	void Profile::Archive()
	{
		m_performances.push(m_current);
		m_current = make_shared<Performance>();
	}

	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	int Profile::GetID() const
	{
		return m_id;
	}

#if !SWIG
	const stack<Profile::PerfPtr>& Profile::GetPerformanceLog()
	{
		return m_performances;
	}

	const Profile::PerfPtr Profile::GetLastLog()
	{
		return m_performances.size() > 0 ? m_performances.top() : nullptr;
	}
#endif
}